import javax.swing.JOptionPane;
/**
 * Create Reader Report GUI and Generate Reader Report/
 * 
 */

public class ReaderReportCONTROL {
	/**
	 * search - data about reader on which the Report will be Generated.
	 */
	public String[] search;
	/**
	 * result - data from DataBase. 
	 */
	public String[] result;
	/**
	 * tmpArray - temporary String array 
	 */
	public String[] tmpArray;
	/**
	 * tmp - temporary String
	 */
	public String tmp;
	/**
	 * Display Reader Report/
	 */
	public ReaderReportResultGui rrg;
	/**
	 * userName - Reader userName
	 */
	public String userName;
	
	/**
	 * Create rrg(ReaderReportResultGui) and Display it
	 * @param s Reader UserName
	 */
	public ReaderReportCONTROL(String s)
	{
		userName=s;
		rrg=new ReaderReportResultGui();
		Main.log.frame.setSize( 415,340 ); // set frame size
		Main.pdmc.pdmug.setVisible(false);
		Main.log.frame.add(rrg);
		rrg.setVisible( true ); // display frame
	}
	/**
	 * Receive data from GUI and  Generate Reader Report and display it
	 */
	public void lsreachUseru()
	{
		search=new String[3];
		search[0]=Main.gusers.id;
		search[1]="searchuserreport";
		search[2]=userName;
		Main.log.connection.accept(search[1]);
		while(Main.log.flag==false);
		Main.log.flag=false;
		tmp=ChatClient.getRs();
		result=tmp.split("\\%");
		if(result[0].equals(""))
		{
			JOptionPane.showMessageDialog(null,"There is no user with this UserName","ERROR",JOptionPane.ERROR_MESSAGE);
			return;
		}
		else
		{
			rrg.setUserName(userName);
			rrg.setList(result);
		}
	}
}
